Repository navigation
fix(MeshHelper): apply submesh baseVertex to triangle indices - #384
nichinichisou0609 wants to merge 1 commit into
Conversation
| @@ -0,0 +1,177 @@ | |||
| import struct | |||
There was a problem hiding this comment.
As in the other PR,
I prefer real assets for the test cases of the Unity object handling functions,
instead of engineered tests, as such tests will always just work for the implemented code.
Ofc they protect against potential future breakage, but don't really provide any real value otherwise,
and instead add a relatively big maintenance cost.
|
Besides the test, looks good, and seems to be correct. |
41e053e to
a6e501b
Compare
|
Thanks for checking it against the docs! Removed the test file and rebased on master, so it's just the change in If a sample helps: the zip has a tiny AssetBundle with one mesh whose second submesh uses |
MeshHandler.get_triangles()returns the stored indices without applying the submesh'sbaseVertex. For a submesh with indices[0, 1, 2]andbaseVertex = 5it returns(0, 1, 2)instead of(5, 6, 7), so anything indexing the mesh's full vertex array (the OBJ exporter included) picks the wrong vertices.Unity defines
SubMeshDescriptor.baseVertexas an offset added to every index (which is also how a 16-bit index buffer can address a larger mesh), andMesh.GetTrianglesapplies it by default.The offset is added after the existing topology conversion, so triangles, strips and quads keep their winding. A missing,
Noneor zerobaseVertexbehaves as before.